#include <iostream>
#include <map>
using namespace std;

bool Statistics(string str_a, string str_b)
{
    if (str_a.size() != str_b.size() ||str_a.empty() || str_b.empty())
    {
        return false;
    }
    map<char, int> map_a, map_b;
    for (size_t i = 0; i < str_a.size(); i++)
    {
        map<char,int>::iterator it_a = map_a.find(str_a.at(i));
        if (it_a == map_a.end())
        {
            map_a.insert(map<char, int>::value_type(str_a.at(i), 1));
        }
        else
        {
            it_a->second++;
        }

        map<char,int>::iterator it_b = map_b.find(str_b.at(i));
        if (it_b == map_b.end())
        {
            map_b.insert(map<char, int>::value_type(str_b.at(i), 1));
        }
        else
        {
            it_b++;
        }
    }

    for (size_t i = 0; i < str_a.size(); i++)
    {
        map<char,int>::iterator it_a, it_b;
        it_a = map_a.find(str_a.at(i));
        it_b = map_b.find(str_a.at(i));
        if (it_a->second != it_b->second)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    cout << "123,2341: " << Statistics("123", "234") << endl;
    cout << "1232,3122: " << Statistics("123", "312") << endl;
}
